<template>
  <div class="login-container">
    <van-nav-bar
      title="注册账号"
      left-arrow
      @click-left="$router.push('/login')"
      class="header"
    />
    <h2>欢迎注册</h2>
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        label="用户名"
        placeholder="请输入手机号"
        :rules="[
          { required: true, message: '请输入手机号' },
          { pattern: /^1[3-9]\d{9}$/, message: '手机号格式错误' },
        ]"
        left-icon="manager"
      />
      <van-field
        v-model="password1"
        type="password"
        name="密码"
        label="密码"
        placeholder="请输入密码"
        :rules="[
          { required: true, message: '请输入密码' },
          { pattern: /\d{6}/, message: '密码最少为6位字符' },
        ]"
        left-icon="lock"
      />
      <van-field
        v-model="password2"
        type="password"
        name="确认密码"
        label="确认密码"
        placeholder="请输入确认密码"
        :rules="[
          {
            required: true,
            message: '请输入正确内容',
          },
          { pattern: /\d{6}/, message: '密码最少为6位字符' },
        ]"
        left-icon="lock"
      />
      <div style="margin: 16px">
        <van-button round block type="info" native-type="submit"
          >提交</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
export default {
  name: "ZhuCeIndex",
  components: {},
  props: {},
  data() {
    return {
      username: "",
      password1: "",
      password2: "",
      isLogin: false,
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onSubmit(values) {
      if (this.password1 === this.password2) {
        console.log("submit", values);
      } else {
        this.$toast("确认密码错误，请核对密码");
      }
    },
  },
};
</script>
<style lang="less" scoped>
.login-container {
  .header {
    background-color: #1989fa;
  }
  /deep/ .van-nav-bar__title {
    color: #fff !important;
  }
  /deep/ .van-nav-bar .van-icon {
    color: #fff !important;
  }
  h2 {
    color: #1989fa;
    font-weight: 400;
    text-align: center;
  }
}
</style>
